/*
 * Copyright (C) 2000-2008 Tan Menglong <TanMenglong@gmail.com>
 * 
 * This code is distributed under GNU Public License 2.0. Follow this URL for details.
 * http://www.opensource.org/licenses/gpl-license.phpl
 * 
 */

package net.ziqiang.sdk.ibatishelper.dao;

import java.sql.*;
import java.util.*;

public class DynamicBean extends HashMap<String, Object>{
	private static final long serialVersionUID = 2258798622286966227L;

	public DynamicBean(){}

	public DynamicBean(Object... args) {  
		put(args);  
	}  

	public int getInt(Object key) {  
		return getInt(key, 0);
	}

	public int getInt(Object key, int defaultInt) {  
		Integer i = (Integer) get(key);  
		return i == null ? defaultInt : i;  
	}

	public String getString(Object key) {  
		return (String) get(key);
	}  

	public java.sql.Date getDate(Object key) {  
		return (java.sql.Date) get(key);
	}  
	
	public long getLong(Object key){
		return (Long)get(key);
	}
	
	public float getFloat(Object key){
		return (Float)get(key);
	}
	
	public String getString(Object key, String defaultValue) {  
		String value = (String) get(key);  
		return value == null ? defaultValue : value;  
	}  

	public Timestamp getTimestamp(Object key) {  
		return (Timestamp) get(key);  
	}  

	public void put(Object... args) {  
		for (int i = 1; i < args.length; i += 2) {  
			put(String.valueOf(args[i - 1]), args[i]);  
		}
	}
}